package com.erdos.hyt.mall.controller;/**
 * @auth Liurong
 * @date 2017/4/5.
 */

import com.erdos.hyt.base.model.HytResponse;
import com.erdos.hyt.base.model.ResponseResultHandler;
import com.erdos.hyt.mall.model.MallConsigneeAddress;
import com.erdos.hyt.mall.service.MallConsigneeAddressService;
import com.sun.org.apache.bcel.internal.generic.FADD;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商城收货地址ctr
 *
 *
 * @author liurong
 * @create 2017/4/5
 **/
@Api(value = "mall API")
@RestController
@RequestMapping(value = "/mall")
public class MallConsigneeAddressController {

    @Autowired
    private MallConsigneeAddressService mallConsigneeAddressService;

    @ApiOperation(value = "添加/修改地址",notes="商城首页列表",httpMethod ="POST")
    @ResponseBody
    @RequestMapping(value = "/saveOrUpdAddress",method = {RequestMethod.POST},produces ="application/json;charset=UTF-8" )
    public HytResponse<MallConsigneeAddress> saveAddress(
            @ApiParam(value = "地址ID（修改时提交）",required = false)@RequestParam(value = "addressId",required = false)
            Integer addressId,
            @ApiParam(value = "用户ID",required = true)@RequestParam(value = "userId",required = true)
            Integer userId,
            @ApiParam(value = "收件人",required = true)@RequestParam(value = "consignee",required = true)
            String consignee,
            @ApiParam(value = "收件电话",required = true)@RequestParam(value = "mobile",required = true)
            String mobile,
            @ApiParam(value = "邮编",required = true)@RequestParam(value = "postNum",required = true)
            String postNum,
            @ApiParam(value = "详细地址",required = true)@RequestParam(value = "address",required = true)
            String address){

       MallConsigneeAddress mallConsigneeAddress= mallConsigneeAddressService.saveOrUpdAddress(addressId, userId, consignee, mobile, postNum, address);
        HytResponse hytResponse=ResponseResultHandler.handleSuccess(mallConsigneeAddress);
        hytResponse.setMessage("操作成功");
        return hytResponse;
    }

}
